home *** CD-ROM | disk | FTP | other *** search
/ Gigantic Games 2 / Gigantic Games 2.iso / pc / _s_ / stratego / strategodocs < prev    next >
Text File  |  1994-12-22  |  21KB  |  415 lines

  1.                         Serial Stratego Version 1.0
  2.  
  3.                         Written By: Daniel Oberlin
  4.  
  5.  
  6.  
  7.  
  8. I. INTRODUCTION
  9.  
  10. Serial Stratego is a program I wrote which allows Stratego to be played on two 
  11. computers linked by a serial connection.  The game Stratego is a strategic 
  12. board game marketed by Milton Bradley.  In this implementation, a serial 
  13. connection can be made by null-modem (direct serial connection), modem, or by 
  14. logging onto a networked computer and using UNIX or INTERNET resources such as 
  15. Talk, Write, or even IRC (Internet Relay Chat).  The program communicates by 
  16. sending packets which are encoded using standard printable ASCII characters 
  17. (like uuencode, see technical section for more information).  It filters out 
  18. all other characters, including anything which is not found between the start 
  19. and stop character which define the packet.  This makes it possible to employ 
  20. resources found on the host computers to create a "virtual-serial" connection 
  21. between the remotely connected computers.  
  22.  
  23. This program was written on the Amiga using the ACE Basic Compiler by David 
  24. Benn.  It has been tested successfully on an Amiga 500 running Kickstart 1.3 
  25. and an Amiga 4000/040.  If you do not have the speak device, you will need to 
  26. obtain it or change a line in the stratego.prefs file (see later section).
  27.  
  28.  
  29.  
  30.  
  31. II. THE RULES OF STRATEGO (skip this if you know them)
  32.  
  33. Stratego is played on a 10*10 board by two players (red and blue).  In the 
  34. middle of the board, there are two "lakes" which occupy 4 squares each. The 
  35. playing pieces of stratego are designed so that their identities remain hidden 
  36. to the opponent (the pieces stand up on the board, and each piece is labelled 
  37. on one side only). Each player begins with 40 playing pieces, and players 
  38. alternate turns, moving one piece into a new square each turn.  If a piece is 
  39. moved into a square that is occupied by one of the opponent's pieces, then 
  40. this is called a strike, and one of the two pieces will be removed from the 
  41. board (according to certain rules).  The object of the game is to capture the 
  42. flag of your opponent, which is one of his pieces.
  43.  
  44. There are 12 different kinds of playing pieces:
  45.  
  46.      Symbol:   Name:          Quantity:
  47.  
  48.      1         Marshall       1
  49.      2         General        1
  50.      3         Colonel        2
  51.      4         Major          3
  52.      5         Captain        4
  53.      6         Lieutenant     4
  54.      7         Sergeant       4
  55.      8         Miner          5
  56.      9         Scouts         8
  57.      S         Spy            1
  58.      *         Bomb           6
  59.      F         Flag           1
  60.  
  61. The pieces are numbered according to their power, the lowest numbers being the 
  62. most powerful.
  63.  
  64. Before the game begins, each player arranges his pieces on his side of the 
  65. board.  All of his pieces must be placed within the four rows closest to his 
  66. side of the board.  For example:
  67.  
  68.  
  69.           BBBBBBBBBB
  70.           BBBBBBBBBB      "B" - Blue Playing Pieces
  71.           BBBBBBBBBB      "R" - Red Playing Pieces
  72.           BBBBBBBBBB      "*" - Empty Squares
  73.           **  **  **      " " - Lake
  74.           **  **  **
  75.           RRRRRRRRRR
  76.           RRRRRRRRRR
  77.           RRRRRRRRRR
  78.           RRRRRRRRRR
  79.  
  80.  
  81. As soon as both players have finished setting up their pieces, the game 
  82. begins.  At this point, neither player knows the identity of any of his 
  83. opponent's pieces.  The red player takes the first turn.
  84.  
  85. All pieces are movable except for the bombs and the flag.  During his turn, a 
  86. player moves one of his movable pieces to an adjacent square (but not 
  87. diagonally).  The Scout (9) is special, and can be moved across any number of 
  88. unoccupied squares (horizontally or vertically).  According to the original 
  89. rules, the scout may not move across multiple squares and strike a piece 
  90. during the same turn, however in this implementation a provision has been made 
  91. so that this rule may be changed.  If this option is selected, then a scout 
  92. may move and strike in the same turn.
  93.  
  94. When a piece strikes an opponent's piece, the identities of both pieces are 
  95. revealed.  The winner is determined by the ranks of the two pieces.  In 
  96. general, a piece may defeat any other piece of a higher number (with one 
  97. exception), and if one piece strikes another piece of the same rank then both 
  98. pieces are lost.  A two will defeat a three or four but not a one, for 
  99. example.  The only exception to this hierarchy is the spy.  Any piece may 
  100. strike the spy and defeat it, but if the spy strikes a Marshall (1), then the 
  101. spy will prevail.  Bombs defeat all pieces except the miner (8).  When the 
  102. attacking piece wins the strike, it is moved into the square occupied by the 
  103. defending piece.  When the defending piece wins the strike, it is moved into 
  104. the square occupied by the attacking piece.  In this implementation, there is 
  105. an option to allow the defending piece to remain in its square when it wins a 
  106. strike (another popular way to play the game).
  107.  
  108. The game is won when one player strikes his opponent's flag or removes all of 
  109. his opponent's pieces.  If a player is unable to move a piece, then he loses.
  110.  
  111.  
  112.  
  113.  
  114. III. USING THE PROGRAM
  115.  
  116. The program may be started from Workbench or the Shell.  If the program does 
  117. not load, make sure that the serial port is not being used by another program.  
  118. Run the program from the Shell to see any error messages.
  119.  
  120. Once loaded, the program will begin a simple terminal program to facilitate 
  121. making a serial connection.  Once the connection is made, you should talk to 
  122. the other player and decide which sides you will be playing.  Then press 
  123. ESCAPE to begin playing the game.  Here are some examples of different ways 
  124. Serial Stratego may be used:
  125.  
  126. Modem-
  127. Use the terminal program to manually dial another computer.  Have the other 
  128. computer answer.  Verify the connection and then press ESCAPE.
  129.  
  130. Null Modem-
  131. Connect two computers with a null modem cable, verify that the connection is 
  132. functioning, and then press ESCAPE.  It may be necessary to change your 
  133. system's serial preferences to "no handshaking" when using a null modem 
  134. connection.
  135.  
  136. Remote login and Talk/Write/IRC-
  137. Use the terminal program to dial a computer on Internet.  Establish a talk 
  138. session with another user, or have both players use the write command to talk 
  139. to each other.  Once the connection has been verified press ESCAPE.  It is 
  140. also possible to use this program with IRC.  Just begin using IRC on the 
  141. remote computer, join a channel with the other player, and then press ESCAPE.  
  142. It is desirable to use the "-d" switch when invoking the IRC client since this 
  143. will eliminate the screen control characters, but stratego will function 
  144. properly without the "-d" switch.  IRC usage may be unreliable at times due to 
  145. netsplits.  The raw serial communications can always be monitored by switching 
  146. screens to the terminal emulator.
  147.  
  148. As soon as ESCAPE is pressed, each player will select his color and a new 
  149. screen will appear with two windows.  One window will contain the board and 
  150. the other will be used for text, messages, and information.
  151.  
  152. When the board is first displayed, the pieces will be arranged in groups 
  153. according to their rank.  Before play begins, the pieces must be set up.  The 
  154. pieces are arranged by exchanging the locations of pieces.  To select a 
  155. particular piece, just move the pointer onto it and click the left mouse 
  156. button.  Then do the same thing for the piece that you want to exchange 
  157. positions with.  When you have set the board up and are ready to continue 
  158. playing, select "Done Setting Up" from the setup menu.  During the setup 
  159. procedure, you may load or save setups stored in five different files.  These 
  160. are also accessed in the setup menu.
  161.  
  162. When you have finished setting up, your opponent will be notified.  When the 
  163. second player is done setting up, the game will begin.  Players take turns 
  164. moving their pieces.  To move a piece, click on the piece and then on the 
  165. square to which you want to move it.  If you decide not to move the piece, 
  166. click on it again to unselect it.  If it is impossible to move any of your 
  167. pieces, if you have run out of pieces to move, or if you would like to concede 
  168. the game, you may select "Concede Game" from the game menu.  Otherwise, the 
  169. game will be finished when a player strikes his opponent's flag.  When your 
  170. opponent moves his pieces, a "+" symbol will be placed on the last piece that 
  171. he moved.  This is done in case a move is made while you are not watching the 
  172. screen.
  173.  
  174. When the game is completed, both players will be notified.  If a player wishes 
  175. to reveal the locations of his remaining pieces to his opponent, he may do so 
  176. by selecting "Reveal Pieces" from the game menu.  At this point, a new game 
  177. may be started or you may return to the terminal emulator using the game menu.  
  178. You will also be returned to the terminal emulator if you click on the board.
  179.  
  180. At any time during the setup, gameplay, or after the game,  you may send 
  181. messages to your opponent.  Select "Send A Message" from the dialog menu, or 
  182. press the associated hotkey (normally this is AMIGA-q, but this can be changed 
  183. in the preferences file).  You may then type a message which will be sent to 
  184. your opponent.  All messages are printed and spoken using the Amiga's SPEAK: 
  185. device.  The last 13 messages that you send are logged, and you can resend 
  186. them quickly by selecting them under the dialog menu.  Message logging may be 
  187. turned off and on using the "Message Buffer is Off/On" menu selections under 
  188. the dialog menu.  This permits you to record certain messages which you may 
  189. want to send frequently and have them easily available via a menu selection.
  190.  
  191. The "Rank Report" selection under the game menu displays the number of pieces 
  192. of each type that you have captured.  This is useful in determining which 
  193. pieces your opponent has left.
  194.  
  195. There are two variations of the stratego rules that may be played.  These are 
  196. controlled by the "Scout Strike" and "Defender Occupies" selections in the 
  197. game menu.  These options may be changed by the red player only.  Normally, a 
  198. player may move his scout across many unoccupied squares, but may not strike 
  199. in the same turn unless it is to an adjacent square.  When the "Scout Strike" 
  200. option in the game menu is enabled, both players may move and strike across 
  201. multiple unoccupied squares with a scout during a single turn.  The other 
  202. option that may be changed concerns the placement of the piece that is being 
  203. attacked in a strike.  If  the piece that is being struck wins, then that 
  204. piece is moved into the square that was occupied by the attacking piece.  If 
  205. the "Defender Occupies" mode is turned off, then the attacked piece will 
  206. remain in its original square if it defeats the attacker.
  207.  
  208. The "Send Ping" menu selection is useful to determine if both programs are 
  209. sending and receiving packets.  When selected, you should send a "Ping..." and 
  210. receive a "Pong" slightly later.  Both of these events should be displayed in 
  211. the text window.  If no "Pong" is received, then there is something wrong with 
  212. the connection.  Wait and send some more "Pings".  If the connection becomes 
  213. re-established, then the "Sanity Check" feature should be used to 
  214. re-synchronize the packet counters on both computers.  If "Ping" is still 
  215. having problems, then return to terminal mode.  The ping function should 
  216. normally be used to verify that the other player is still there if you haven't 
  217. heard from him (maybe his computer crashed, or the modem was disconnected, 
  218. etc.).
  219.  
  220. Another diagnostic is the "Sanity Check" under the game menu.  This has two 
  221. functions. It checks to make sure that the pieces are arranged in the same way 
  222. on both boards (this may not be the case if some packets were completely lost 
  223. during the game because of bad line noise or other circumstances).  The 
  224. "Sanity Check" will report a fatal error if the boards do not match.  The 
  225. second feature of the sanity check function is the synchronization of packet 
  226. counters on both computers.  Each computer keeps track of how many messages 
  227. have been sent by the other, so that if there is an error, a re-send may be 
  228. requested.  If a packet is completely lost and undetected for some reason, 
  229. then these numbers will be inconsistent.  The sanity check will check for an 
  230. inconsistency in the packet counters and automatically correct it ("Sync 
  231. Error" will be displayed).
  232.  
  233.  
  234.  
  235.  
  236. IV.  THE PREFERENCES FILE
  237.  
  238. The file "stratego.prefs" contains a few parameters that may be modified to 
  239. suit your needs.  The following is a listing of the standard preferences file:
  240.  
  241. -------------------- Begin file after this line.
  242. 19200
  243. N81SF
  244. serial.device
  245. 0
  246. q
  247. SPEAK:
  248. $%&'
  249. 0
  250. -------------------- File ends with previous line.
  251.  
  252.  
  253. Here is a detailed description of the elements of the preferences file:
  254.  
  255. Line #:    Description:
  256.  
  257. 1             The baud rate of your serial connection.
  258.  
  259. 2             The ACE parameters for opening the serial device:
  260.  
  261.     N/E/O Parity none, even, odd
  262.     8/7 bits per word
  263.     0/1 stop bit
  264.         3 - 3 wire handshaking (optional)
  265.     S - Shared access to serial device (optional)
  266.     F - Fast serial mode (optional)
  267.  
  268. 3         The name of the serial device.  Maybe you would like to use the AUW 
  269. device or a faster serial device instead.  Just put the name of the device 
  270. that you want to use here.
  271.  
  272. 4         The unit number of the serial device.
  273.  
  274. 5         The hot-key for the "Send Message" menu selection. Due to a problem 
  275. in this version of ACE, the menu and keyboard can't be polled simultaneously, 
  276. so I can't make the program start recording a message when you press a key on 
  277. the keyboard.  The best that I could come up with was to include a hot-key to 
  278. select the menu option to initiate typing a message.
  279.  
  280. 6         The name of  the device/file that you want spoken text to be 
  281. directed to.  If you don't have the speak device with your version of 
  282. AmigaDOS, get it from someone or direct this to NIL: or another device 
  283. instead.  You can also change the sound of voice by adding parameters to the 
  284. end of the device name (see AmigaDOS manuals).
  285.  
  286. 7         The four characters that are used to mark the beginning and ending 
  287. of packets sent by both players.  This line MUST be the same for both players.  
  288. this should only be changed when the characters that are being used might 
  289. interfere with the connection in some way (see technical notes).
  290.  
  291. 8         Miscellaneous flags.  Currently contains a 0 to use SLEEP for 
  292. polling the keyboard during message typing and terminal mode (sometimes 
  293. keypresses are missed with this implementation of ACE), or a 1 to busy wait 
  294. the keyboard during these events (works better, but uses resources heavily).  
  295. I know this is tacky.  Should be fixed in later versions of this program (when 
  296. a new version of ACE is released).
  297.  
  298.  
  299.  
  300.  
  301. V. TECHNICAL NOTES (how the packet subroutines work)
  302.  
  303. I have always found it neat that you can talk to people on other networked 
  304. computers around the world for free.  The "talk" program on most UNIX machines 
  305. allows you to call up another person on a different computer connected to the 
  306. network.  You can then carry on a conversation by typing text, character by 
  307. character, to the other person's screen.  The "write" program lets you type 
  308. and send sentences of text to another person's screen (provided that they are 
  309. logged on to the same computer).  When two people "write" to each other, they 
  310. can carry on a conversation by taking turns sending lines of text and pressing 
  311. return after each line.  Internet Relay Chat lets groups of people on 
  312. different computers talk and send messages to each other on different 
  313. channels.
  314.  
  315. I am also interested in multiplayer computer games.  The only problems with 
  316. modem or null-modem type games are that it costs money to play games over long 
  317. distances and it is difficult to find ways to connect more than two players 
  318. using modems.  
  319.  
  320. This gave me the idea to develop some subroutines which would encode strings 
  321. into packets which could be sent as normal text and thus be transmitted 
  322. through the network via programs that were intended to be used for 
  323. communicating text in real-time.  One subroutine would take as input a 
  324. character string, encode it, and send it.  The other routine would monitor the 
  325. serial device, decode packets, and return them to the program.  In many ways 
  326. this is similar to network layers which provide an "invisible" channel through 
  327. which to communicate.  My subroutines convert these network resources into 
  328. "virtual-serial" connections between two remotely connected computers.
  329.  
  330. I wanted the subroutines to be as generally useful as possible, so I decided 
  331. to use only standard ASCII printable characters to encode the packets.  This 
  332. implementation uses characters 63-126 and 36-39.  Characters 63-126 are used 
  333. to send data, and 36-39 are used to mark the beginnings and endings of 
  334. packets.  In order to prevent interference between messages that are sent and 
  335. echoed back (the remote computer sends back everything that you type so you 
  336. can see it), and what the other player sends you, I divided the usable 
  337. characters into two portions- one for each player.  The packet send routine 
  338. uses only the characters allowed for that player and includes a CR (carriage 
  339. return) at the end of each packet ("write" requires a CR before a sentence is 
  340. sent to the other terminal).  The packet receive routine filters out all 
  341. characters except those of the kind sent by the other player.  In addition, it 
  342. filters out ALL characters that are not found between a packet begin and 
  343. packet end character.  This means that anything not contained inside the 
  344. packet delimiters will be filtered out and ignored.  In addition, VT-100 
  345. screen escape sequences are filtered from input inside of each packet.  The 
  346. four characters that are used to define a packet begin, and end, for both 
  347. players may be changed if they interfere with the communication method.  These 
  348. characters are located in the preferences file, but should be changed with the 
  349. understanding that both players must have the same string on this line in 
  350. their preferences file or the programs will not communicate.
  351.  
  352. A simple checksum is used for error detection (this could be improved by 
  353. implementing a CRC checksum), and a data timeout is detected when a certain 
  354. amount of time elapses after a packet begin is received, but no packet end is 
  355. received.  If an error is detected, a resend can be requested.  The previous 
  356. 10 packets sent (including resends and resend requests) are buffered so that 
  357. if extreme durations of line noise occur, all packets can be eventually 
  358. recovered.  All errors and resends are displayed in the text window, notifying 
  359. the players.
  360.  
  361. If anyone is interested in writing more multiplayer games in ACE, I would be 
  362. more than happy to donate these subroutines and assist in their implementation 
  363. into a program.
  364.  
  365.  
  366.  
  367.  
  368. VII. MISCELLANEOUS INFORMATION
  369.  
  370. I would appreciate hearing from anyone who has suggestions, bug reports, or an 
  371. interest in playing stratego with this program.  In fact, please send me 
  372. E-mail just letting me know that you have tried my program and under what 
  373. circumstances.  If you have an interest in using the packet sending/receiving 
  374. subroutines to write other games with ACE, I would be happy to provide the 
  375. source code.  Here is how I can be reached (start with the top E-mail address, 
  376. the others are longer term but checked less frequently):
  377.  
  378. fkrj@crux2.cit.cornell.edu
  379. oberlin@chemres.tn.cornell.edu
  380. doberlin@math.fsu.edu
  381.  
  382. IRC Nicks: obi1, DogMaps.  Generally found on channel #amiga.
  383.  
  384.  
  385. Program History:
  386. Version 1.0 - beta test versions.
  387. Version 1.2 - contains many added features and enhancements.
  388. Version 1.3 - first public release.
  389.  
  390. Future plans:
  391. When a new version of ACE is released, I plan to fix a few problems.  
  392. Hopefully, in the new version of ACE, it will be possible to simultaneously 
  393. poll the menu and the keyboard.  If this correction is made, then I will add a 
  394. feature that will allow you to start typing on the keyboard to begin a message 
  395. rather than selecting it from the menu or with a hotkey.  This improvement to 
  396. ACE would also allow me to add menu macros to the terminal emulator for 
  397. dialing phone numbers, logging on, etc.  If the sleep feature is improved, 
  398. this will eliminate the need for OPTIONAL polling of the keyboard (see 
  399. preferences file) using a busy-wait.  If people show enough interest, I might 
  400. also add AmiTCP support as well.  
  401.  
  402.  
  403. Acknowledgments:
  404.  
  405. David Benn-
  406. for writing the ACE compiler used to compile this program.  I really like ACE 
  407. a lot and hope that it will be developed further.
  408.  
  409. My brother Richard-
  410. who patiently tested the program with me.
  411.  
  412. Amiga-
  413. the best microcomputer platform.
  414.  
  415.